package org.ytor.core.sqlflow.dsl.eval.function.support;

import org.ytor.core.sqlflow.dsl.expr.node.support.FunctionCallNode;
import org.ytor.core.sqlflow.dsl.eval.function.Func;
import org.ytor.common.util.Colls;
import org.ytor.common.util.Dates;

import java.util.List;

/**
 * created by yangtong on 2025/8/7 00:18:08
 * <br/>
 * 获取当前时间
 */
public class Now implements Func {
    @Override
    public Boolean support(FunctionCallNode functionCallNode) {
        return functionCallNode.functionName.equalsIgnoreCase("now");
    }

    @Override
    public Object call(List<Object> args) {
        if (Colls.isNotEmpty(args)) {
            throw new IllegalArgumentException("now函数不能有参数：now()");
        }

        return Dates.now();
    }
}
